<?php
namespace app\member\controller;
use think\Controller;
class Admin extends Controller{
    public function login() {
        if (request()->isPost()){
            $data = input();
            //校验用户名密码
            $manager = check_login($data['username'], $data['password']);
            if ($manager===false) {
                die("{\"code\":\"1001\",\"msg\":\"用户名或密码错误！\"}");
            }
            setSession("manager",$manager);
            die("{\"code\":0,\"msg\":\"管理员登录成功！\",\"url\":\"".url('Manager/index')."\"}");
        }
        return $this->fetch();
    }
    /**
     * 注销登录
     */
    public function logout(){
        setSession("manager", null);
        $this->success("注销成功！",url('admin/login'));
    }
}